home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11815 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  917 b 

  1. Path: castle.nando.net!news
  2. From: actuary@nando.net   (Bill McCarthy)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Rand() Function
  5. Date: 26 Mar 1996 21:16:08 GMT
  6. Organization: Nando.net Public Access
  7. Message-ID: <4j9mqo$c0h@castle.nando.net>
  8. References: <4iqltj$40g@news1.sympatico.ca>
  9. Reply-To: actuary@nando.net (Bill McCarthy)
  10. NNTP-Posting-Host: grail1819.nando.net
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4iqltj$40g@news1.sympatico.ca>, Gisele Swinson <gisele.swinson@sympatico.ca> writes:
  14. >How do I get a random number from a "SET" of numbers.
  15. >
  16. >e.g.
  17. >
  18. >      I want a random number from this set:
  19. >
  20. >      2, 4, 6, 8, 10
  21. >
  22. >It seems so simple but I can't find anything in my text how to do this.
  23.  
  24. It is!  See the FAQ.  It explains how to write a function to to return a
  25. "random" number from 0 to n-1.  Once you have a number from 0 to 4,
  26. add 1, then double the sum.
  27.  
  28. Bill McCarthy
  29. actuary@nando.net
  30. Wendell, NC  USA
  31.  
  32.